package com.ai.speek;

import java.util.LinkedList;
import java.util.Queue;

public class AudioPlayer {

	// 音频内容队列
	private static Queue<String> speekQueue = new LinkedList<String>();

	// 输入
	public void say(String content) {
		speekQueue.offer(content);
		play();
	}

	private boolean speaking = false;

	// 输出
	public void play() {
		// System.out.println(speekQueue);
		if (speaking) {
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			play();
		} else {
			String content = speekQueue.poll();
			if (content != null && !"".equals(content)) {
				mTts.startSpeaking(content, mSynListener);
			}
		}
	}

}
